package com.example.ivos.geofence.controller;

import com.example.ivos.base.response.JsonResult;
import com.example.ivos.geofence.pojo.dto.GeofenceQuery;
import com.example.ivos.geofence.pojo.dto.GeofenceSaveParam;
import com.example.ivos.geofence.pojo.vo.GeofenceVO;
import com.example.ivos.geofence.service.GeofenceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/geofence")
public class GeofenceController {
    @Autowired
    GeofenceService geofenceService;

    @GetMapping("select")
    public JsonResult selectGeofence(GeofenceQuery geofenceQuery){
        log.debug("查询围栏信息:geofenceQuery={}",geofenceQuery);
        List<GeofenceVO> list = geofenceService.selectGeofence(geofenceQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("addGeofence")
    public JsonResult addGeofence(GeofenceSaveParam geofenceSaveParam){
        log.debug("添加围栏信息:geofenceSaveParam={}",geofenceSaveParam);
        geofenceService.addGeofence(geofenceSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("delete/{id}")
    public JsonResult deleteGeofence(@PathVariable Long id){
        log.debug("删除围栏信息:id={}",id);
        geofenceService.deleteGeofence(id);
        return JsonResult.ok();
    }
}